﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using iCollect.CustomComponent;
using iCollect.util;
using System.Collections;
using iCollect.Constants;

namespace iCollect.CollectDetail
{
    public partial class Device2Monitor : BaseDeviceMonitor
    {
        public Device2Monitor()
        {
            InitializeComponent();
            setEvent();
        }

        protected override void createTextBoxMap()
        {
            //tbMap.Add("TE1", tbTE1);
            //tbMap.Add("TE2", tbTE2);
            //tbMap.Add("TE3", tbTE3);
            //tbMap.Add("TE4", tbTE4);
            //tbMap.Add("TE5", tbTE5);

            //tbMap.Add("PT1", tbPT1);

            tbMap.Add("VT1X", tbVT1X);
            tbMap.Add("VTIY", tbVT1Y);
            tbMap.Add("VT2X", tbVT2X);
            tbMap.Add("VT2Y", tbVT2Y);
            tbMap.Add("VT3X", tbVT3X);
            tbMap.Add("VT3Y", tbVT3Y);
            tbMap.Add("VT4X", tbVT4X);
            tbMap.Add("VT4Y", tbVT4Y);

            NIUtil.getInstance().initTask(tbMap.Keys.ToArray<String>());
        }

        override protected void readFromDevice()
        {
            NIUtil.getInstance().readData();
        }
        
        override protected void displayValue()
        {
            for (int i = 0; i < tbMap.Keys.Count; i++)
            {
                string key = tbMap.Keys.ElementAt(i);
                List<ArrayList> itemList = GlobalConstants.currentData[key];
                ArrayList timeValue = itemList[itemList.Count - 1];
                Double channelValue = Convert.ToDouble(timeValue[1]);
                setTextBoxValue(channelValue, key);
            }
        }
                            
    }
}
